﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Web.UI;
using Discuz.Config;
using Discuz.Web.Services.API.Actions;
using Discuz.Common;
using System.Reflection;
using Discuz.Web.Services.API;
using System.Web;
using System.Collections;
using System.Security.Cryptography;
using Discuz.Forum;
using Newtonsoft.Json;
using System.Data;


namespace Discuz.Web.Services
{
    public class getBoCorpJSON : Page
    {
        private static ErrorDetails _errorDetails = new ErrorDetails();
        public getBoCorpJSON()
        {
            this.Load += new EventHandler(getBoCorpJSON_Load);
        }

        void getBoCorpJSON_Load(object sender, EventArgs e)
        {
            
            Response.Clear();
            //Response.ContentType = "text/xml";
            StringBuilder sb = new StringBuilder();
            try
            {
                DataView dw = Discuz.Forum.Users.GetTYCorp();
                sb.AppendLine("[");
                foreach (DataRowView dr in dw)
                {
                    sb.Append("{");
                    var id = dr[0];
                    var name = dr[1];
                    sb.AppendFormat("'id':'{0}','name':'{1}'", id, name);
                    sb.Append("},");
                }
                if (dw.Count > 0)
                {
                    sb.Remove(sb.Length - 1, 1);
                }
                sb.AppendLine("]");

                Response.Write(sb.ToString());
            }
            catch (Exception ex)
            {
                Response.Write("0");
            }
            Response.End();

        }

    }
}
